//
//  MyQASectionHeaderView.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/15.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "MyQASectionHeaderView.h"

@implementation MyQASectionHeaderView


+(CGFloat)calculateHWithModel:(CommonQAModel *)model {
    
    CGFloat topPading = 5;//距离顶部的距离
    
    CGFloat xiajiaHeight = 30;//
    if ([model.isUp isEqualToString:@"1"]) {//下架
        xiajiaHeight = 30;
    } else {
        xiajiaHeight = CGFLOAT_MIN;
    }
    
    CGFloat labHeight = 30;//文字高度可计算
    CGFloat bottomHeight = 30;//底部
    CGFloat bottomPading = 5;//距离

    return topPading + xiajiaHeight + labHeight + bottomHeight + bottomPading;
}

- (void)fillWithModel:(CommonQAModel *)model {
    
    self.timeLab.text = [NSString stringWithFormat:@"发布于：%@",model.createTime];
    self.contentLab.text = model.title;

    self.huidaLab.text = [NSString stringWithFormat:@"%@回答",model.answerNumber];
    
    if ([model.isUp isEqualToString:@"1"]) {//下架
        self.xiajiaHeight.constant = 30;
    } else {
        self.xiajiaHeight.constant = CGFLOAT_MIN;
    }
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.xiajiaBtn pp_clipCorners:UIRectCornerAllCorners radius:self.xiajiaBtn.frame.size.height/2 border:1 color:UIColorHex(0xFF7200)];
    });
    
}

- (IBAction)deleteAction:(id)sender {
    if (self.MyQASectionHeaderViewBlock) {
        self.MyQASectionHeaderViewBlock(MyQASectionHeaderActionType_del);
    }
}


@end
